package cn.alex.sso.project.controller;

import cn.alex.sso.framework.core.Result;
import cn.alex.sso.project.service.StatisticsService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * 统计
 *
 * @author Alex
 * @date 2025/1/13 下午12:43
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/statistics")
public class StatisticsController {
    private final StatisticsService statisticsService;

    /**
     * 查询总数据
     *
     * @return Map
     * userTotal:总计用户
     * clientTotal:应用总计
     * loginTotal:应用总计访问量
     * onlineTotal:在线用户
     */
    @GetMapping("/getTotal")
    public Result getTotal() {
        return Result.ok(statisticsService.getTotal());
    }

    /**
     * 查询应用排行榜
     *
     * @param params 查询参数
     * @return List
     */
    @GetMapping("/getClientRankList")
    public Result getClientRankList(@RequestParam Map<String, String> params) {
        return Result.ok(statisticsService.getClientRankList(params));
    }

    /**
     * 查询应用访问记录统计
     *
     * @param params 查询参数
     * @return List
     */
    @GetMapping("/getClientVisitStc")
    public Result getClientVisitStc(@RequestParam Map<String, String> params) {
        return Result.ok(statisticsService.getClientVisitStc(params));
    }

}
